<template>
  <div class="managebox">
    <div class="formbox">
      <el-form ref="form" :model="form">
        <el-form-item>
          <el-input
            v-model="form.account"
            prefix-icon="el-icon-notebook-2"
            placeholder="请输入登陆账号"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            placeholder="请输入密码"
            prefix-icon="el-icon-lock"
            v-model="form.passWord"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">登陆</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { Login, GetreadCom } from "../../api/index"

export default {
  data() {
    return {
      form: {
        account: "",
        passWord: "",
      },
    }
  },
  methods: {
    async onSubmit() {
      let res = await Login({
        account: this.form.account,
        passWord: this.form.passWord,
      })
      if (res.status) {
        this.$notify({
          title: "成功",
          message: res.msg,
          type: "success",
        })
        this.$EventBus.$emit("changeIsLogin")
        this.$router.push("/backend")
        let result = await GetreadCom()
        this.$store.commit("pushCom", result.data)
        this.$store.commit("upDateStaus", true)
      } else {
        this.$message.error(res.msg)
      }

      // axios.post("api/login",{userName: this.form.userName,passWord: this.form.passWord}).then(res=>{
      //     console.log(res);
      // })
    },
  },
}
</script>
<style lang="scss" scoped>
.managebox {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.formbox {
  border-radius: 10px;
  width: 400px;
  height: 200px;
  text-align: center;
  background: white;
}
.formbox {
  padding: 0px 30px;
  padding-top: 40px;
}
</style>
